<?php  
require(__DIR__.'/phpmailer/Php_Mailer.php');

class EmailClient {

	public $mailer = NULL;
	public $initialized = FALSE;
	
	function EmailClient($config)
	{
		if (count($config) > 0)
		{
			$this->initialize($config);
			$this->initialized = TRUE;
			echo 'debug', "EmailClient Class Initialized\r\n";
		} 
		else
		{
			echo 'debug', "EmailClient Class Initialized\r\n";
			
		}
	}

	
	/*
	 * Initialize preferences
	 */
	function initialize($config = array())
	{
		set_time_limit(200);
		
		if($config['protocol'] == 'smtp') 
		{
			ini_set("SMTP", $config['smtp_host']);
			ini_set("smtp_port", $config['smtp_port']);
		}
		
		$this->mailer = new PHP_Mailer();


		if($config['protocol'] == 'mail') 
		{
			$this->mailer->IsSendmail(); // telling the class to use Sendmail
		}
		
		else if($config['protocol'] == 'smtp') 
		{
			$this->mailer->IsSMTP(); // telling the class to use SMTP
			$this->mailer->Host = $config['smtp_host'];
			$this->mailer->SMTPAuth = $config['smtp_autheticate'] === TRUE; // enable SMTP authentication
			$this->mailer->Port = $config['smtp_port'];
			$this->mailer->Username = $config['smtp_username']; // SMTP account username
			$this->mailer->Password = $config['smtp_password']; // SMTP account password
		}
		$this->mailer->SetFrom($config['from_email'], $config['from_username']);
	}
  
	
}
	
// END EmailClient class